package com.sky.controller.courier;

import com.sky.pojo.Courier;
import com.sky.result.Result;
import com.sky.service.courier.CourierService;
import com.sky.service.courier.CourierTradeOrderService;
import com.sky.service.user.OrderDispatchService;
import com.sky.vo.CourierTradeOrderDetailVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description CourierController
 * @Author lyh
 * @Date 2024-11-04
 */
@RestController
@Api(tags = "骑手端骑手")
@RequestMapping("/courier")
public class CourierController {
    @Autowired
    private CourierTradeOrderService tradeOrderService;
    @Autowired
    private OrderDispatchService orderDispatchService;
    @Autowired
    private CourierService courierService;
    @ApiOperation("骑手端接单")
    @GetMapping("/receivingOrder")
    public Result<String> receivingOrder(Long courierId,String tradeNo){
        tradeOrderService.receivingOrder(courierId,tradeNo);
       return Result.success();
    }
    @GetMapping("/transferOrderToTaskPool")
    @ApiOperation("转派")
    public Result transferOrderToTaskPool(Long tradeNo,Long courierId){
        Courier courier = orderDispatchService.dispatchCourier(null, tradeNo,courierId);
        return Result.success(courier);
    }
    @GetMapping("/findById")
    @ApiOperation("根据骑手的id查询骑手的信息")
    public Result<Courier> findById(Long id){
        Courier courier=courierService.findById(id);
        return Result.success(courier);
    }

    /**
     * 骑手的月度统计
     * @param courierId
     * @param date
     * @return
     */
    @GetMapping("/findCourierMonthTradeOrderInfo")
    @ApiOperation("骑手的月度统计")
    public Result<CourierTradeOrderDetailVO> findCourierMonthTradeOrderInfo(Long courierId, String date){
        CourierTradeOrderDetailVO courierTradeOrderDetailVO=courierService.findCourierMonthTradeOrderInfo(courierId,date);
        return Result.success(courierTradeOrderDetailVO);
    }
}
